import router from '@/routers';

export const getQueryParam = () => {
  const route: any = router.currentRoute;
  if (route.value?.query.params) {
    return JSON.parse(route.value.query.params);
  }
};
// vue router
export const routerPush = (path: string, params?: any) => {
  let data = {};
  if (params) {
    data = {
      params: JSON.stringify(params)
    };
  } else {
    data = {};
  }
  router.push({
    path,
    query: data
  });
};

export const routerReplace = (path: string, params?: any) => {
  let data = {};
  if (params) {
    data = {
      params: JSON.stringify(params)
    };
  } else {
    data = {};
  }
  router.replace({
    path,
    query: data
  });
};

export const routeInfo = () => {
  return router.currentRoute;
};
export const routerBack = () => {
  router.go(-1);
};
